const Router = require('koa-router');
const router = new Router({
    prefix: '/v1/user'
});

const {
    registerValidator
} = require('../../validators/validator')

const User = require('../../models/user')

const success = require('../../lib/helper')

router.post('/register', async (ctx, next) => {
  const v = await new registerValidator().validate(ctx);
  const user = {
      email: v.get('body.email'),
      password: v.get('body.password1'),
      nickname: v.get('body.nickname')
  }
  User.create(user);
  success();
})

module.exports = router;